<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
                <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
                <title></title>
                <link rel="stylesheet" href="__PUBLIC__/Css/bootstrap.min.css" />
                <link rel="stylesheet" href="__PUBLIC__/Css/common.css" />
                <jquery/>
                <script type="text/javascript" src='__PUBLIC__/Js/goods.js'></script>
                <script type="text/javascript">
                        $(function() {
                                $('select[name=type_tid]').change(function() {
                                         var oVal = $(this).val();
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=TypeAttr&a=ajax_attr',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success:function(data){
                                                        if(data){
                                                                $('#spec tr.info td').html('该类型下暂时没有添加商品规格或者您还没有选择类型！');
                                                                $('#attr tr.info td').html('该类型下暂时没有添加商品属性或者您还没有选择类型！')
                                                                $.each(data,function(k,v){
                                                                                        if(v.class==1){
                                                                                                if($('#spec tr.info td').html()=='该类型下暂时没有添加商品规格或者您还没有选择类型！'){
                                                                                                        $('#spec tr.info td').html('');
                                                                                                }
                                                                                                oRadio='<dl style="padding-left:10px;float:left;padding-bottom:10px;"><dt style="padding-left:10px;padding-bottom:10px;padding-top:10px;font-size:16px;">'+v.taname+'</dt>';
                                                                                                var tempArr =new Array();
                                                                                                tempArr = v.tavalue.split(',');
                                                                                                for(i=0;i<tempArr.length;i++){
                                                                                                        oRadio+='<dd style="float:left;width:300px;padding-right:15px;"><label style="float:left;"><input type="checkbox" class="standard" name="standard_'+v.taid+'['+i+']" style="float:left;margin-right:10px;" value="'+tempArr[i]+'">'+'<p style="float:right">'+tempArr[i]+'</p></label><input type="text" style="float:right;width:170px;" placeholder="附加价格,不需要可以不填" name="standard_'+v.taid+'_'+i+'_added"></dd>';
                                                                                                }
                                                                                                oRadio+='</dl>';
                                                                                                $('#spec tr.info td').append(oRadio);
                                                                                        }
                                                                                        if(v.class==0){
                                                                                                if($('#attr tr.info td').html()=='该类型下暂时没有添加商品属性或者您还没有选择类型！'){
                                                                                                        $('#attr tr.info td').html('');
                                                                                                }
                                                                                                oSelect='<select name="attr_'+v.taid+'" style="margin:10px;">';
                                                                                                var tempArr2 =new Array();
                                                                                                tempArr2 = v.tavalue.split(',');
                                                                                                for(i=0;i<tempArr2.length;i++){
                                                                                                        oSelect+= '<option value="'+tempArr2[i]+'">'+tempArr2[i]+'</option>';
                                                                                                }
                                                                                                oSelect+='</select>附加价格 : &nbsp;<input type="text" placeholder="附加价格，不需要可以不填" style="margin:0px;" name="attr_'+v.taid+'_added"><br/>';
                                                                                                $('#attr tr.info td').append(oSelect);
                                                                                        }
                                                                        })
                                                                  }
                                                           }
                                                 })
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=Category&a=ajax_cate',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success: function(data) {
                                                        var option = '<option value="0">-----------请选择-----------</option>';
                                                        if (data) {
                                                                $.each(data, function(k, v) {
                                                                        if(v.pid!=0){
                                                                                option += '<option value=' + v.cid +'>' + v._name + '</option>';
                                                                        }else{
                                                                                option += '<option value=' + v.cid + ' disabled="disabled">' + v._name + '</option>';
                                                                        }
                                                                })
                                                        }
                                                        $('select[name=cid]').html('');
                                                        $('select[name=cid]').append(option);
                                                }
                                        })
                                        $.ajax({
                                                url: '__MODULE__' + '&m=Admin&c=Brand&a=ajax_brand',
                                                data: {tid: oVal},
                                                dataType: 'json',
                                                type: 'post',
                                                success: function(data) {
                                                        var option = '<option value="0">-----------请选择-----------</option>';
                                                        if (data) {
                                                                $.each(data, function(k, v) {
                                                                                option += '<option value=' + v.bid +'>' + v.bname + '</option>';     
                                                                })
                                                        }
                                                        $('select[name=bid]').html('');
                                                        $('select[name=bid]').append(option);
                                                }
                                        })
                                })
                        })
                </script>
        </head>
        <body>
                <div class="container-fluid">
                        <div class="row-fluid">
                                <div class="span12">
                                        <form action="" method='post'>
                                                <fieldset>
                                                        <legend>添加商品</legend>
                                                        <table class='table table-bordered table-hover'>
                                                                <thead>
                                                                        <tr>
                                                                                <th colspan="2" class="btn btn-primary">基本信息</th>
                                                                        </tr>
                                                                </thead>
                                                                <tbody>
                                                                        <tr class="info">
                                                                                <td>所属类型</td>
                                                                                <td>
                                                                                        <select name="type_tid">
                                                                                                <option value="0">-----------请选择-----------</option>
                                                                                                <foreach from='$typeInfo' value='$v'>
                                                                                                        <option value="{$v.tid}">{$v.tname}</option>
                                                                                                </foreach>
                                                                                        </select>
                                                                                        <span class='help-inline help'>----------注:所属类型,分类,品牌请先手动添加再选择----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>所属分类</td>
                                                                                <td>
                                                                                        <select name="cid">
                                                                                                <option value="0">-----------请选择------------</option>
                                                                                        </select>
                                                                                        <span class='help-inline help'>----------注:请先选择所属类型,顶级分类不能添加商品----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>所属品牌</td>
                                                                                <td>
                                                                                        <select name="bid">
                                                                                                <option value="0">-----------请选择-----------</option>
                                                                                                <foreach from='$brandInfo' value='$v'>
                                                                                                        <option value="{$v.bid}">{$v.bname}</option>
                                                                                                </foreach>
                                                                                        </select>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>商品名称</td>
                                                                                <td>
                                                                                        <input type="text" name='gname'/>
                                                                                        <span class='help-inline help'>----------注:商品标题最多45个字符----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>商品次标题</td>
                                                                                <td>
                                                                                        <input type="text" name='lhname'/>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>单位</td>
                                                                                <td>
                                                                                        <input type="text" name='unit' value='件'/>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>市价场</td>
                                                                                <td>
                                                                                        <input type="text" name='mprice'/>
                                                                                        <span class='help-inline help'>----------注:价格为敏感区域，请谨慎填写----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>京东价</td>
                                                                                <td>
                                                                                        <input type="text" name='jdprice'/>
                                                                                        <span class='help-inline help'>----------注:价格为敏感区域，请谨慎填写----------</span>
                                                                                </td>
                                                                        </tr>
                                                                        <tr class="info">
                                                                                <td>点击次数</td>
                                                                                <td>
                                                                                        <input type="text" name='click'/>
                                                                                </td>
                                                                        </tr>
                                                                         <tr class="info">
                                                                                <td>商品库存</td>
                                                                                <td>
                                                                                        <input type="text" name='stock'/>
                                                                                </td>
                                                                        </tr>
                                                                </tbody>
                                                        </table>

                                                        <p class="btn btn-primary">商品属性</p>
                                                        <table class="table table-bordered table-hover" id='attr' class="info">
                                                                <tr class="info"><td>该类型下暂时没有添加商品属性或者您还没有选择类型！</td></tr>
                                                        </table>
                                                        <p class="btn btn-primary">商品规格</p>
                                                        <table class="table table-bordered table-hover" id='spec'>
                                                                <tr class="info"><td>该类型下暂时没有添加商品规格或者您还没有选择类型！</td></tr>
                                                        </table>

                                                        <table class='table table-bordered'>
                                                                <tr>
                                                                        <th colspan="2" class="btn btn-primary">列表图</th>
                                                                </tr>
                                                                <tr class="info">
                                                                        <td>上传图片</td>
                                                                        <td>
                                                                                <upload  name='listimg' alt="false" water="false" limit='1' waterbtn="false" dir="upload/listimg/" width="80" height="40" size="1"/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table table-bordered'>
                                                                <tr>
                                                                        <th colspan="2" class="btn btn-primary">商品图</th>
                                                                </tr>
                                                                <tr class="info">
                                                                        <td>上传图片</td>
                                                                        <td>
                                                                                <upload  name='thumb' alt="false" water="false" limit='10' waterbtn="false" dir="upload/goodimg/" width="80" height="50" size="1"/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table'>
                                                                <tr class="next_show">
                                                                        <th class="btn btn-primary">商品详细<i class='ico'></i></th>
                                                                </tr>
                                                                <tr class="info hide">
                                                                        <td>
                                                                                <ueditor name='detailCon'/>
                                                                        </td>
                                                                </tr>
                                                        </table>

                                                        <table class='table'>
                                                                <tr class="next_show">
                                                                        <th class="btn btn-primary">售后服务<i class='ico'></i></th>
                                                                </tr>
                                                                <tr class="info hide">
                                                                        <td>
                                                                                <ueditor name='service'/>
                                                                        </td>
                                                                </tr>
                                                        </table>
                                                        <div><input type="submit" value="确认添加" class="btn btn-primary btn-lg btn-block" /><br/><br/><br/><br/></div>
                                                </fieldset>
                                        </form>

                                </div>
                        </div>
                </div>
        </body>
</html>